package top.mataiji.manager.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import mataiji.config.util.Result;
import top.mataiji.manager.pojo.User;
import top.mataiji.manager.service.UserService;

/**
 * @Auther: zhaoss
 * @Date: 2021/3/28 - 03 - 28 - 15:49
 * @Description: top.mataiji.manager.controller
 * @version: 1.0
 * 个人信息页面
 */
@RestController
@RequestMapping("user")
public class UserController {

    @Autowired
    UserService userService;

    @RequestMapping("findUserById")
    public User findUserById(Integer userId){
        System.out.println(userId);
        return  userService.finduserById(userId);
    }

    @RequestMapping("register")
    public Result register(User user){
        System.out.println(user);
        user.setIntegral(10000);
        user.setUserStatus(1L);
        userService.register(user);
        return Result.error("注册成功");
    }

    @RequestMapping("verify")
    public int verify(String loginname){
        System.out.println(loginname);
        return userService.verifyName(loginname);
    }

    @RequestMapping("alterInformation")
    public Result alterInformation(User user){
        int i = userService.alterInformation(user);
        if(i!=0){
            return Result.success("修改成功");
        }
        return Result.error("修改失败");
    }
}
